package com.cty.api;

import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("api")
public class ApiController {

    @Autowired
    ServletContext servletContext;
    /*
    *
    *
    * 获取原生api对象
    *
    * */
    @RequestMapping
    public String data(HttpServletResponse response,
                       HttpServletRequest request,
                       HttpSession session) {
        //第一种方法:获取servletContext对象
        ServletContext servletContext = session.getServletContext();
        ServletContext servletContext1 = request.getServletContext();
        //第二种方法:用ioc容器获取,在项目启动时，会在ioc容器中自动装配servletContext对象
        return null;
    }
}
